home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / pp / icm-pp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-01  |  2.0 KB  |  70 lines

  1. /*
  2. \funcref{main}{void main (\params)}
  3.     {
  4.         {int} {argc} {argument count}
  5.         {char} {**argv} {pointer to array of argument strings}
  6.     }
  7.     {}
  8.     {error(), pushfile(), lexer(), process()}
  9.     {}
  10.     {icm-pp.c}
  11.     {
  12.         Function {\em main()} checks if two arguments are present on the
  13.         invoking command line. If not, an error occurs.
  14.  
  15.         The environment variable {\em IM} is inspected to ensure that
  16.         included files are searched from this directory. When not set,
  17.         included files are searched in the current directory.
  18.  
  19.         Next the input- and output files are opened. The input file is opened
  20.         using function {\em pushfile()}. The output file is pointed to by {\em
  21.         FILE $*$outfile}.
  22.  
  23.         To process the input, function {\em lexer()} is called and its return
  24.         value is passed to {\em process()}. This is repeated until the
  25.         filestack pointer {\em filesp} (increased by {\em pushfile()},
  26.         decreased by {\em popfile()}) indicates that the file stack is empty.
  27.     }
  28. */
  29.  
  30.  
  31. #ifdef MSDOS
  32. #    define LIBREQUEST
  33. #    pragma comment (lib, "icmpp")
  34. #    pragma comment (lib, "../rss/icrss")
  35. #endif
  36.  
  37. #include "icm-pp.h"
  38.  
  39. void main (int argc, char **argv)
  40. {
  41.     register char
  42.         *progname;
  43.  
  44.     if (argc != 3)
  45.     {
  46.         copyright ("ICMAKE Preprocessor", version, release, 1);
  47.         progname = program_name (argv [0]);
  48.         printf ("This program is run as a child process of icmake.\n"
  49.                 "Usage: %s inputfile outputfile\n"
  50.                 "where: inputfile  - makefile in text format\n"
  51.                 "       outputfile - result of preprocessing\n\n"
  52.             , progname);
  53.         exit (1);
  54.     }
  55.  
  56.     if (! (imdir = getenv ("IM")) )
  57.         imdir = ".";
  58.  
  59.     if (! (outfile = fopen (argv [2], "w")) )
  60.         error ("cannot open input file %s", argv [2]);
  61.     pushfile (argv [1]);
  62.  
  63.     loadsym();                              /* platform specific #define's */
  64.  
  65.     while (filesp >= 0)
  66.         process (lexer ());
  67.  
  68.     exit (0);
  69. }
  70.